const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sunnyClient', {
    id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "主键"
    },
    clientId: {
      type: DataTypes.STRING(48),
      allowNull: false,
      comment: "客户端id",
      field: 'client_id'
    },
    clientSecret: {
      type: DataTypes.STRING(256),
      allowNull: false,
      comment: "客户端密钥",
      field: 'client_secret'
    },
    resourceIds: {
      type: DataTypes.STRING(256),
      allowNull: true,
      comment: "资源集合",
      field: 'resource_ids'
    },
    scope: {
      type: DataTypes.STRING(256),
      allowNull: false,
      comment: "授权范围"
    },
    authorizedGrantTypes: {
      type: DataTypes.STRING(256),
      allowNull: false,
      comment: "授权类型",
      field: 'authorized_grant_types'
    },
    webServerRedirectUri: {
      type: DataTypes.STRING(256),
      allowNull: true,
      comment: "回调地址",
      field: 'web_server_redirect_uri'
    },
    authorities: {
      type: DataTypes.STRING(256),
      allowNull: true,
      comment: "权限"
    },
    accessTokenValidity: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "令牌过期秒数",
      field: 'access_token_validity'
    },
    refreshTokenValidity: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "刷新令牌过期秒数",
      field: 'refresh_token_validity'
    },
    additionalInformation: {
      type: DataTypes.STRING(4096),
      allowNull: true,
      comment: "附加说明",
      field: 'additional_information'
    },
    autoapprove: {
      type: DataTypes.STRING(256),
      allowNull: true,
      comment: "自动授权"
    },
    createUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建人",
      field: 'create_user'
    },
    createDept: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建部门",
      field: 'create_dept'
    },
    createTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "创建时间",
      field: 'create_time'
    },
    updateUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "修改人",
      field: 'update_user'
    },
    updateTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "修改时间",
      field: 'update_time'
    },
    status: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "状态"
    },
    isDeleted: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "是否已删除",
      field: 'is_deleted'
    }
  }, {
    sequelize,
    tableName: 'sunny_client',
    timestamps: true,
    createdAt: 'createTime',
    updatedAt: 'updateTime',
    deletedAt: 'deleteTime',
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
